import 'dart:core';

import '../utils/screw.dart';

class TopicItem {
  int id;
  String topic;
  String label;
  String detail;
  String addition;

  TopicItem({this.id, this.topic, this.label, this.detail, this.addition});

  TopicItem.fromMap(Map<String, dynamic> json)
      : id = json['id'],
        topic = json['topic'],
        label = json['label'],
        detail = json['detail'],
        addition = json['addition'];

  Map<String, dynamic> toMap() => {
        'id': id,
        'topic': topic,
        'label': label,
        'detail': detail,
        'addition': addition
      };

  String md5() {
    var body = '$topic,$label,$detail,$addition';
    return Screw.genMD5(body);
  }

  static List<TopicItem> genFromList(List data) {
    return List.from(data).map((e) => TopicItem.fromMap(e)).toList();
  }
}
